#include "KSADHitsCollection.hh"
#include "KSADHit.hh"
#include "KSADGlobals.hh"

KSADHitsCollection::KSADHitsCollection(G4String detName,G4String colName):G4VHitsCollection(detName,colName)
{
	size = 0;
	collection = new KSADHit*[0];
}

KSADHitsCollection::~KSADHitsCollection()
{
	for(size_t l = 0;l < size;l++) delete collection[l];
	delete collection;
}

G4VHit* KSADHitsCollection::GetHit(size_t index) const
{
	return collection[index];
}

size_t KSADHitsCollection::GetSize() const
{
	return size;
}

void KSADHitsCollection::Insert(KSADHit* newHit)
{
	KSADHit** collectionOld = collection;

	collection = new KSADHit*[size+1];
	
	for(size_t l = 0;l < size;l++) collection[l] = collectionOld[l];
	delete collectionOld;

	size++;

	collection[size-1] = newHit;
}
